package com.inspur.iaic.service;

import java.util.concurrent.LinkedBlockingQueue;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.inspur.iaic.config.NginxLogProperties;
import com.inspur.iaic.data.NginxLog;

/**
 * 预警日志处理器
 *
 */
@Component
@Scope("singleton")
public class RealTimeAccessLogProcessor extends LogProcessor {
	private int capacity = 600;

	@Autowired
	private LogSendService logSendService;

	public RealTimeAccessLogProcessor(NginxLogProperties nginxLogProperties) {
		super();
		capacity = nginxLogProperties.getRealTimeAccessLogCacheCapacity();
		setNginxLogQueue(new LinkedBlockingQueue<NginxLog>(capacity));
	}

	@Override
	public void handle(NginxLog log) {
		logSendService.send("/log/access/realtime", log);
	}

	public int getCapacity() {
		return capacity;
	}

	public void setCapacity(int capacity) {
		this.capacity = capacity;
	}
}
